import java.util.Scanner;

public class RecursionTest {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
//        System.out.println(factor(n));
//        positvPrint1(n);
//        positvPrint2(n);
//        System.out.println(sum(n));
//        System.out.println(sumBit(n));
//        System.out.println(fib(n));
        hanoi(n,'A','B','C');
    }

    /**
     * 汉诺塔移动次序
     * @param n 起始位置有n个盘子
     * @param pos1 起始位置
     * @param pos2 中介位置
     * @param pos3 目标位置
     */
    public static void hanoi(int n,char pos1,char pos2,char pos3){
        if(n == 1){
            move(pos1,pos3);
            return;
        }
        hanoi(n - 1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n - 1,pos2,pos1,pos3);
    }
    public static void move(char pos1,char pos2){
        System.out.print(pos1 + " -> " + pos2 + " ");
    }

    /**
     * 每一位相加求和
     * @param n
     * @return
     */
    public static int sumBit(int n){
        if(n < 10){
            return n;
        }
        return (sumBit(n/10) + n % 10);
    }
    public static int sum(int n){
        if(n == 1){
            return n;
        }
        return (n + sum(n - 1));
    }
    public static int factor(int n){
        if(n == 1){
            return n;
        }
        return (n * factor(n - 1));
    }
    public static void positvPrint1(int n){
        if(n < 10){
            System.out.print(n + " ");
            return;
        }
        positvPrint1(n/10);
        System.out.print(n % 10 + " ");
    }
    public static void positvPrint2(int n){
        if(n > 10){
            positvPrint2(n/10);
        }
        System.out.print(n % 10 + " ");
    }
    public static int fib(int n){
        if(n == 1 || n == 2){
            return 1;
        }
        return fib(n - 1) + fib(n - 2);
    }
}
